<style>
.table th { border:1px solid #aaa;
			background: #e9e9e9;
			color: #666666;
			padding: 4px 8px;
			text-align: left;
			white-space: nowrap;
			height: 32px;
			line-height: 32px;}
.table td {
	border:1px solid #aaa;
	
}

</style>


<script language="javascript" type="text/javascript" src="/js/my97datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/object.js"></script>
<script type="text/javascript" src="/js/object_ready.js"></script>
<script type="text/javascript" src="/js/address.js"></script>
<script type="text/javascript" src="/js/park.js"></script>
<script type="text/javascript" src="/js/school.js"></script>



<script>
$(document).ready(function(){



$( "#case_name_123" ).autocomplete({
            source: function(request, response ) {
                $.ajax({
                    //url: "/client/client_josn",
                    ///js/blog/public/abc
                    url: "/js/blog/public/abc",
                    dataType: "json",
                    data:{
                        query: request.term
                    },
                    success: function( data ) {
                        response( $.map( data, function( item ) {
                            return {
                                label: item.case_name,
                                value: item.case_name,
                                recommended: item.recommended
                            }
                        }));
                    }
                });
            },
            select: function(e, ui) {
              $("#recommended").val(ui.item.recommended);
            },
            minLength: 1
    });	

$( "#building_name123" ).autocomplete({
            source: function(request, response ) {
                $.ajax({
                    //url: "/client/client_josn",
                    ///js/blog/public/abc
                    url: "/js/blog/public/market/building_name",
                    dataType: "json",
                    data:{
                        query: request.term
                    },
                    success: function( data ) {
                        response( $.map( data, function( item ) {
                            return {
                                label: item.building_name,
                                value: item.building_name,
                                recommended: item.recommended
                            }
                        }));
                    }
                });
            },
            select: function(e, ui) {
              $("#recommended").val(ui.item.recommended);
            },
            minLength: 1
    }); 

//building_name123
	
	
	
	$("#object_usage123123")
	  .bind( 'focus', function(){ 
		
	  	$(this).autocomplete("search"); 

	  }).bind( 'click', function(){ 

	  	$(this).autocomplete("search"); 
	  	
	  } )
	  .autocomplete({
		minLength: 0,
		source: function(request, response ) {
			//alert(request.term);
	                $.ajax({
	                    url: "/object_usage/object_usage_josn",
	                    dataType: "json",
	                    data:{
						query: request.term
	                    },
	                    success: function( data ) {

	                        response( $.map( data, function( item ) {
	                        return {
								label: item.value,
								value: item.value
	                        }
	                        }));
	                    }
	                });
	    },
		focus: function() {
		  return false;
		},
		select: function( event, ui ) {
			 var terms=new Array();
			 if(this.value!="")
			   terms = this.value.split("/ ");
			 terms.pop();
			 terms.push( ui.item.value );
			 terms.push( "" );
			 this.value = terms.join( "/ " );
			 return false;
		}
	  });
	  
	  
	  
	  // $( "#case_name_123" )
   //    //.bind( 'focus', function(){ 
   //    //	$(this).autocomplete("search"); 
   //    //} )
   //    .bind( 'click', function(){ 
   //    	$(this).autocomplete("search"); 
   //    } )
   //    .autocomplete({
   //      minLength: 0,
   //      source: function(request, response ) {
   //              $.ajax({
   //                  url: "/object/case_name_josn",
   //                  dataType: "json",
   //                  data:{
			// 			query: request.term
   //                  },
   //                  success: function( data ) {
   //                      response( $.map( data, function( item ) {
   //                      return {
			// 			label: item.value,
			// 			value: item.value
   //                      }
   //                      }));
   //                  }
   //              });
	  //   },
   //      focus: function() {
   //        return false;
   //      }
      //});	



});
</script> 

<script type="text/Javascript" src="/js/market.js"></script>
 <link href="/css/bootstrap/dist/css/bootstrap.css" type="text/css" rel="stylesheet">

        <form method="POST"  id="userinfo">

            <table class="table" <?=empty($_POST)?'style="display:none;"':""?>>
                <tbody>
                    <tr>
                        <th>顧客</th>
                        <td>
                            <input type="text"  name="owner" id="owner" 
                            value="<?=!empty($_POST["owner"])?$_POST["owner"]:""?>"
                            >

                        </td>

                        <th>售租案</th>
                        <td>
                            <input type="checkbox" 
                            value="1" id="type_rent" name="type_rent">租賃
                            <input type="checkbox" value="2" id="type_sale" name="type_sale">買賣
                          
                        </td>
                    </tr>

                    <tr>
                        <th>建物門牌</th>
                        <td>
                            行政區&nbsp;
                            <input type="text"
                                   id="administrative_area123"
                                   name="administrative_area"
                                   value="<?=!empty($_POST["administrative_area"])?$_POST["administrative_area"]:""?>"
                                   onclick="show_administrative_area('administrative_area123');" style="width:120px;">&nbsp;

                            <input type="text"
                                   style="width:60%;"
                                   id="house_building_qwe"
                                   name="house_building"
                                   value="<?=!empty($_POST["house_building"])?$_POST["house_building"]:""?>"
                                   onclick="show_hous_ebuilding('house_building_qwe');">

                        </td>
                        <th>區域</th>
                        <td>
                            <input type="text"  name="area"
                            value="<?=!empty($_POST["area"])?$_POST["area"]:""?>"
                            id="areaasd" onclick="show_emphasis_area('areaasd')">
                        </td>
                    </tr>


                    <tr>
                        <th>案名</th>
                        <td>
                        	
                        	<input id="case_name_123" 
                            value="<?=!empty($_POST["case_name"])?$_POST["case_name"]:""?>"
                            name="case_name" size="50" style="width:148px;"  />
                            
                        </td>
                        <th>大樓名稱</th>
                        <td>
                            <input type="text" class="full_select" 
                            value="<?=!empty($_POST["building_name"])? $_POST["building_name"]:""?>"
                            style="width:200px;" name="building_name" id="building_name123">
                            
                        </td>
                    </tr>
                    <tr>
                        <th>物件用途</th>
                        <td>
                        		<input type="text" 
                        		value="<?=!empty($_POST["object_usage"])?$_POST["object_usage"]:""?>"
                        		name="object_usage" 
                        		id="object_usage123123" >
                        		
                           
                        </td>
                        <th>市調狀態</th>
                        <td>
                            <input type="text" name="object_state" id="obj_mark" style="width: 200px;">  
                            
                        </td>
                    </tr>
                    <tr>
                        <th>建物面積</th>
                        <td>
                            <input type="text" name="building_area1" 
                            value="<?=!empty($_POST["building_area1"])?$_POST["building_area1"]:""?>"
                            id="building_area1"> ~ 

                            <input type="text" name="building_area2" 
                            value="<?=!empty($_POST["building_area2"])?$_POST["building_area2"]:""?>"
                            id="building_area2">坪
                        </td>
                        <th>土地面積</th>
                        <td>
                            <input type="text" 
                            value="<?=!empty($_POST["base_area1"])?$_POST["base_area1"]:""?>"
                            name="base_area1" id="base_area1">~<input type="text" name="base_area2" id="base_area2">坪</td>
                    </tr>
                    <tr>
                        <th>總價</th>
                        <td>
                            <input type="text" name="total1" id="total1" 
                            value="<?=!empty($_POST["total1"])?$_POST["total1"]:""?>"
                            > ~ 
                            <input type="text" name="total2" id="total2" 
                            value="<?=!empty($_POST["total2"])?$_POST["total2"]:""?>"
                            >萬</td>
                        <th>範圍<br>
                            <input type="button" value="設定" onclick="show_range_map();" class="input_background">
                        </th>
                        <td>緯度 <input type="text" name="latitude1" id="latitude1"
                                value="<?=!empty($_POST["latitude1"])?$_POST["latitude1"]:""?>"> ~ 
                                <input type="text" name="latitude2" id="latitude2"
                                value="<?=!empty($_POST["latitude2"])?$_POST["latitude2"]:""?>"
                                ><br>
                            經度 <input type="text" name="longitude1" id="longitude" 
                            value="<?=!empty($_POST["longitude1"])?$_POST["longitude1"]:""?>"> ~ 
                                <input type="text" name="longitude2" id="longitude2"
                                value="<?=!empty($_POST["longitude2"])?$_POST["longitude2"]:""?>">
                        </td>
                    </tr>
                    <tr>
                        <th>物件案別</th>
                        <td><input type="checkbox" value="1" name="object_case_type[]">中古屋 &nbsp;&nbsp;
                            <input type="checkbox" value="2" name="object_case_type[]">預售 &nbsp;&nbsp;
                            <input type="checkbox" value="3" name="object_case_type[]">標售</td>
                        <th>屋齡</th>
                        <td><input type="text" name="year_of_construction1" 
                            value="<?=!empty($_POST["year_of_construction1"])?$_POST["year_of_construction1"]:""?>"
                            id="year_of_construction1">年~
                            <input type="text" name="year_of_construction2" 
                            value="<?=!empty($_POST["year_of_construction2"])?$_POST["year_of_construction2"]:""?>"
                            id="year_of_construction2">年</td>
                    </tr>
                    <tr>
                        <th>經紀人</th>
                        <td colspan="3">

                        	<select name="broker" id="broker">
				    		<option></option>
					    	<?php
					    	foreach($borkers as $broker):
								echo '<option value="'.$broker->users_id.'" ';
                            ?>

                            <?=!empty($_POST["broker"])?( $_POST["broker"]==$broker->users_id ?' selected ':'' ):"";?>

                            <?php
                                echo ' >'.$broker->name.'</option>';
						    endforeach;
					    	?>
					    	</select>


                        </td>
                    </tr>


                    <tr style="display:none;">
                        <th>委託起日</th>
                        <td><input type="text" class="Wdate" style="width:100px;"  
                            value="<?=!empty($_POST["entrust_start1"])?$_POST["entrust_start1"]:""?>"
                            onclick="WdatePicker()" name="entrust_start1" id="entrust_start1"> ~ 
                            <input type="text" class="Wdate" onclick="WdatePicker()"
                            value="<?=!empty($_POST["entrust_start2"])?$_POST["entrust_start2"]:""?>"
                             style="width:100px;" name="entrust_start2" id="entrust_start2"></td>
                        <th>委託迄日</th>
                        <td><input type="text" class="Wdate" onclick="WdatePicker()"
                            value="<?=!empty($_POST["entrust_end1"])?$_POST["entrust_end1"]:""?>"
                            style="width:100px;" name="entrust_end1"  id="entrust_end1"> ~ 
                         <input type="text" class="Wdate" onclick="WdatePicker()" 
                         value="<?=!empty($_POST["entrust_end2"])?$_POST["entrust_end2"]:""?>"
                         style="width:100px;" name="entrust_end2" id="entrust_end2"></td>
                    </tr>


                    <tr>
                        <th>排序</th>
                        <td>
                            <select class="full_select" style="width:100px;" name="orderby" id="orderby">
                                <option value="ctime">建檔日期</option>
                            </select>
                            &nbsp;
                            <select class="full_select" style="width:100px;" name="sort"  id="sort">
                                <option value="desc"
                                <?=!empty($_POST["sort"])?( $_POST["sort"]=="desc" ?' selected ':'' ):"";?>
                                >降冪排列</option>
                                <option value="asc"
                                <?=!empty($_POST["sort"])?( $_POST["sort"]=="asc"?' selected ':'' ):"";?>
                                >升冪排列</option>
                            </select>
                        </td>
                        <th>密件</th>
                        <td><input type="radio" value="N" name="bcc" id="bcc"

                            >否
                            <input type="radio" value="Y" name="bcc" id="bcc">是
                        </td>
                    </tr>

                    <tr>
                        <th>市調編號</th>
                        <td><input type="text"  name="object_no" id="object_no"
                            value="<?=!empty($_POST["object_no"])?$_POST["object_no"]:""?>"
                            ></td>
                        <th>所在樓層</th>
                        <td>
                        		<input type="text"  name="floor1" id="floor1"
                                value="<?=!empty($_POST["floor1"])?$_POST["floor1"]:""?>"
                                > 
                        			~
                            <input type="text"  name="floor2" id="floor2"
                            value="<?=!empty($_POST["floor2"])?$_POST["floor2"]:""?>"
                            >
                        </td>
                    </tr>

                    <tr>
                        <th>關鍵字</th>
                        <td><input type="text" name="keywords" id="keywords"
                            value="<?=!empty($_POST["keywords"])?$_POST["keywords"]:""?>"
                            ></td>
                        <th>建檔日期</th>
                        <td><input type="text" class="Wdate" style="width:100px;" 
                            value="<?=!empty($_POST["sctime"])?$_POST["sctime"]:""?>"
                            onclick="WdatePicker()" name="sctime" id="sctime"> ~ 

                            <input type="text" class="Wdate" style="width:100px;" 
                            value="<?=!empty($_POST["ectime"])?$_POST["ectime"]:""?>"
                            onclick="WdatePicker()" name="ectime" id="ectime"></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td colspan="3">
                            <input type="submit" value="查詢確認" class="input_background">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    



    <div id="administrative_area_select" style="display: none;">

        <div id="city_div"  style="float:left;padding:10px">
            <h3>縣市</h3>
            <select onchange="administrative_area_city_choose();" style="width:102px;" size="30" id="administrative_city">
                <option value="">請選擇</option>
                <?
                foreach($address_city as $key=>$val){
                ?>
                <option value="<?= $val->id ?>"><?= $val->name ?></option>
                <?
                }
                ?>
            </select>
        </div>

        <div id="area_div"  style="float:left;padding:10px;width:102px;">
            <h3>區域</h3>
            <select onchange="administrative_area_choose();" style="width:102px;" size="30" id="administrative_country">
                <option value="">請選擇</option>
            </select>
        </div>
        <div style="clear: both;"></div>
        <div id="addr_div" style="padding:10px">
            <input type="text" value="" id="administrative_area_value" >
        </div>

    </div>


    <div id="emphasis_area_select" style="display: none;"  class="form_style">
        <table class="windows_choose">
            <thead>
                <tr>
                    <th>選擇</th>
                    <th>重點區域</th>
                    <th>說明</th>

                </tr>
            </thead>
            <tbody>
                <?
                foreach($emphasis_area as $key=>$val){
                ?>
                <tr id="t_<?= $val->emphasis_area_id ?>">
                    <td><input type="radio" value="<?= $val->value ?>" name="emphasis_area_value" id="emphasis_area_value"></td>
                    <td><?= $val->value ?></td>
                    <td><?= $val->explanation ?></td>
                </tr>
                <?
                }
                ?>
            </tbody>
        </table>
    </div>


    <div id="hous_ebuilding_select" style="display: none;">
        <div id="area_div"  style="float:left;padding:10px;width:102px;display: none;">
            <h3>行政區</h3>

            <select name="hous_ebuilding_administrative_area"
                    id="hous_ebuilding_administrative_area"
                    style="width:102px;" size="20"
                    onchange="hous_ebuilding_administrative_area_choose();">

                <option value="">請選擇</option>
                <?
                foreach($administrative_area as $key=>$val){
                ?>
                <option value="<?= $val->id ?>"><?= $val->name ?></option>
                <?
                }
                ?>
            </select>
        </div>

        <div id="street_div" style="float:left;padding:10px">
            <h3>街道</h3>
            <select onchange="hous_ebuilding_street_choose()" style="width:102px;" size="20" id="hous_ebuilding_street">
                <option value="">請選擇</option>
            </select>
        </div>

        <div id="other_div" style="float:left;padding:10px">
            <h3>其它</h3>

            <div>
                <input type="button" onclick="hous_ebuilding_word_choose('thousand')" value="千" class="button" name="thousand" id="thousand">
                <input type="button" onclick="hous_ebuilding_word_choose('village')" value="村" class="button" name="village" id="village">
                <input type="button" onclick="hous_ebuilding_word_choose('in')" value="里" class="button" name="in" id="in">
                <input type="button" onclick="hous_ebuilding_word_choose('neighbor')" value="鄰" class="button" name="neighbor" id="neighbor">
            </div>

            <div>
                <input type="button" onclick="hous_ebuilding_word_choose('road')" value="路" class="button" name="road" id="road">
                <input type="button" onclick="hous_ebuilding_word_choose('word_street')" value="街" class="button" name="word_street" id="word_street">
                <input type="button" onclick="hous_ebuilding_word_choose('paragraph')" value="段" class="button" name="paragraph" id="paragraph">
                <input type="button" onclick="hous_ebuilding_word_choose('lane')" value="巷" class="button" name="lane" id="lane">
            </div>

            <div>
                <input type="button" onclick="hous_ebuilding_word_choose('get')" value="弄" class="button" name="get" id="get">
                <input type="button" onclick="hous_ebuilding_word_choose('number')" value="號" class="button" name="number" id="number">
                <input type="button" onclick="hous_ebuilding_word_choose('floor')" value="樓" class="button" name="floor" id="floor">
                <input type="button" onclick="hous_ebuilding_word_choose('room')" value="室" class="button" name="room" id="room">
            </div>

            <div>
                <input type="button" onclick="hous_ebuilding_word_choose('the')" value="之" class="button" name="the" id="the">
                <input type="button" onclick="hous_ebuilding_word_choose('del')" value="Del" class="button" name="del" id="del">
            </div>
            <div>
                <input type="button" onclick="hous_ebuilding_word_choose('number_1')" value="1" class="button" name="number_1" id="number_1">
                <input type="button" onclick="hous_ebuilding_word_choose('number_2')" value="2" class="button" name="number_2" id="number_2">
                <input type="button" onclick="hous_ebuilding_word_choose('number_3')" value="3" class="button" name="number_3" id="number_3">
                <input type="button" onclick="hous_ebuilding_word_choose('number_4')" value="4" class="button" name="number_4" id="number_4">
                <input type="button" onclick="hous_ebuilding_word_choose('number_5')" value="5" class="button" name="number_5" id="number_5">
            </div>
            <div>
                <input type="button" onclick="hous_ebuilding_word_choose('number_6')" value="6" class="button" name="number_6" id="number_6">
                <input type="button" onclick="hous_ebuilding_word_choose('number_7')" value="7" class="button" name="number_7" id="number_7">
                <input type="button" onclick="hous_ebuilding_word_choose('number_8')" value="8" class="button" name="number_8" id="number_8">
                <input type="button" onclick="hous_ebuilding_word_choose('number_9')" value="9" class="button" name="number_9" id="number_9">
                <input type="button" onclick="hous_ebuilding_word_choose('number_0')" value="0" class="button" name="number_0" id="number_0">
            </div>
        </div>
        <div style="clear: both;"></div>
        <div id="addr_div" style="padding:10px">
            <input type="text" value="" id="hous_ebuilding_address" style="width:400px;">
        </div>

    </div>




    <div id="range_map_select" style="display: none;" >
        <div id="mycontrol" style="z-index: 0; position: absolute; top: 0px; left: 346px;"><div id="start">開始選取</div><div id="end">結束選取</div></div>
        <div id="map_canvas" style="width:620px;height:600px"></div>
        <div>
            (東北)纬度：<input type="text" id="_latitude1">经度：<input type="text" id="_longitude1"><br>
            (西南)纬度：<input type="text" id="_latitude2">经度：<input type="text" id="_longitude2"><br>
            <span style="color:red;">選取過程中，點擊所選區域以確定基本選區,選區大小可修改，選區可拖動(注：默認顯示台北市)</span>
        </div>
    </div>
    